var skill = {
	_getCardFactoryList: function() {
		if (!Array.isArray(this.card_factory_list)) {
			this.card_factory_list = [];
			this.save();
		}
		return this.card_factory_list;
	},
	//非安全，添加会员专区标识
	_addToCardFactoryList: function(card_factory_id) {
		this._getCardFactoryList().push(card_factory_id);
		this.save();
		return this.card_factory_list;
	},
	_removeFromCardFactoryList: function(card_factory_id) {
		this.card_factory_list = $Array.remove(this._addToCardFactoryList(), card_factory_id);
		this.save();
		if (!this.card_factory_list.length) {
			this.destroy();
		}
		return this.card_factory_list;
	},
	//获取商品会员卡价格，只针对打折
	getCardCash: function() {
		var goods = this;
		var card_cash_map = goods.card_cash_map || (goods.card_cash_map = {});
		var cash = goods.cash;
		var bus = BusCon.get(this.bus_id);
		bus.getCardFactoryList().forEach(function(card_factory) {
			//必须已经执行过getCash
			var discount;
			var card_cash = card_cash_map[card_factory._id] || cash;
			if (card_factory.info.type === CardFactoryCon.TYPE.打折 && (discount = +card_factory.info.config.discount)) {
				card_cash = cash - discount * cash;
			}
			card_cash_map[card_factory._id] = card_cash;
		});
	}
};
module.exports = skill;
var db = require("../db/index");
var config = require("../_include/config");
var CardFactoryCon = require("../card_factory/_con");
var UserAddressCon = require("../user_address/_con");
var AchCon = require("../ach/_con");
var data_cut = require("../_include/data_cut");
var CommentCon = require("../comment/_con");
var EvaluationCon = require("../eval/_con");
var ClassifyCon = require("../bus.classify/_con");
var TagCon = require("../bus.tag/_con");
var BusCon = require("../bus/_con");
var ExpressCon = require("../bus.express/_con");
var BuffCon = require("../buff/_con");
var buffCode = require("../buff/buff_code");
var $Object = require("../_include/$.Object");
var $Array = require("../_include/$.Array");
var helper = require("../_include/helper");
var xss = require("xss");